const mysql = require('mysql2')
const connection = mysql.createConnection({
  host: "localhost",
  user: "root",
  password: "123456",
  database: "tea-culture"

})
connection.connect();
//插入数据
let name = '测试名'
let pwd = 123
connection.query('insert into user value(?,?,?,?)', [0, name, pwd, 0], (err, results, fields) => {
  console.log(results)
})
//搜索数据
connection.query('select * from user', (err, results, fields) => {
  if (err) { throw err }
  console.log(results)
})
//搜索特定的数据
connection.query('select * from user where  uname=? and upwd=?', [name, pwd], (err, results, fields) => {
  console.log(results)
})
//删除
connection.query(`delete from user where uname=?`, name, (err, results, fields) => {
  console.log(results)
})
//更新
connection.query(`update user set (????) where 条件`, [0, name, pwd, 0], (err, results, fields) => {
  console.log(results)
})


connection.end()